/**
 * @author : cyb1010
 * @date   : 2024-06-11 09:23:52
 * @file   : graph.cpp
 */
#include <bits/stdc++.h>
using namespace std;
#define fo(s) freopen(s ".in", "r", stdin), freopen(s ".out", "w", stdout)
#define fi first
#define se second
#define ALL(v) (v).begin(), (v).end()
#define SZ(v) int(v.size())
typedef double db;
typedef long double ldb;
typedef long long ll;
typedef unsigned long long ull;
void ckmx(int &x, int y) { x < y && (x = y); }
void ckmn(int &x, int y) { x > y && (x = y); }
mt19937_64 rnd(time(NULL));
const int N = 200010;
int __, n, m, q;
vector<pair<int, int>> g[N];
ull val[N], p[64];
bool used[N];
void dfs(int p, int fa) {
    used[p] = 1;
    for (auto [x, id] : g[p]) {
        if (id == fa) continue;
        if (used[x]) {
            if (!val[id]) val[id] = rnd();
            val[fa] ^= val[id];
            continue;
        }
        dfs(x, id), val[fa] ^= val[id];
    }
}
int main() {
    fo("graph");
    cin.tie(0)->sync_with_stdio(0);
    cin >> n >> m;
    for (int i = 1, x, y; i <= m; i++)
        cin >> x >> y, g[x].emplace_back(y, i), g[y].emplace_back(x, i);
    dfs(1, 0), cin >> q;
    for (int k, x; q--;) {
        cin >> k, memset(p, 0, sizeof(p));
        auto ins = [&](ull x) {
            for (int i = 63; ~i; i--)
                if (x >> i) {
                    if (!p[i]) return p[i] = x, 0;
                    x ^= p[i];
                }
            return 1;
        };
        bool ans = 0;
        while (k--) cin >> x, ans |= ins(val[x]);
        cout << (ans ? "NO\n" : "YES\n");
    }
    return 0 ^ __ ^ 0;
}